﻿using System.Data;
using ContractManagementSystem.DataAccess;
using ContractManagementSystem.Entity;


namespace ContractManagementSystem.BusinessLogic
{
    public static class LineManagerBusiness
    {
        public static string ErrorMessage { get; set; }
        private static LineManagerDataAccess _lineManagerDataAccess;

        /// <summary>
        /// Function Select All LineManager
        /// Author: Group2.DucDM
        /// </summary>
        /// <param name="activeType"></param>
        /// <returns></returns>
        public static DataTable FetchAll(int activeType)
        {
            _lineManagerDataAccess = new LineManagerDataAccess();
            if (_lineManagerDataAccess.FetchAll(activeType) == null)
            {
                ErrorMessage = _lineManagerDataAccess.ErrorMessage;
            }
            return _lineManagerDataAccess.FetchAll(activeType);
        }

        /// <summary>
        /// Function SearchFullName
        /// Author: Group2.DucDM
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static DataTable SearchFullName(string name)
        {
            _lineManagerDataAccess = new LineManagerDataAccess();
            if (_lineManagerDataAccess.SearchFullName(name) == null)
            {
                ErrorMessage = _lineManagerDataAccess.ErrorMessage;
            }
            return _lineManagerDataAccess.SearchFullName(name);
        }

        /// <summary>
        /// Function Select By Id LineManager
        /// Author: Group2.DucDM
        /// </summary>
        /// <param name="lineManagerEntity"></param>
        /// <returns></returns>
        public static DataTable FetchById(LineManagerEntity lineManagerEntity)
        {
            _lineManagerDataAccess = new LineManagerDataAccess();
            if (_lineManagerDataAccess.FetchById(lineManagerEntity) == null)
            {
                ErrorMessage = _lineManagerDataAccess.ErrorMessage;
            }
            return _lineManagerDataAccess.FetchById(lineManagerEntity);
        }

        /// <summary>
        /// Function Insert LineManager
        /// Author: Group2.DucDM
        /// </summary>
        /// <param name="lineManagerEntity"></param>
        /// <returns></returns>
        public static bool Insert(LineManagerEntity lineManagerEntity)
        {
            _lineManagerDataAccess = new LineManagerDataAccess();
            if (_lineManagerDataAccess.Insert(lineManagerEntity))
            {
                return true;
            }
            ErrorMessage = _lineManagerDataAccess.ErrorMessage;
            return false;
        }

        /// <summary>
        /// Function Update LineManager
        /// Author: Group2.DucDM
        /// </summary>
        /// <param name="lineManagerEntity"></param>
        /// <returns></returns>
        public static bool Update(LineManagerEntity lineManagerEntity)
        {
            _lineManagerDataAccess = new LineManagerDataAccess();
            if (_lineManagerDataAccess.Update(lineManagerEntity))
            {
                return true;
            }
            ErrorMessage = _lineManagerDataAccess.ErrorMessage;
            return false;
        }

        /// <summary>
        /// Function Delete LineManager
        /// Author: Group2.DucDM
        /// </summary>
        /// <param name="lineManagerEntity"></param>
        /// <returns></returns>
        public static bool Delete(LineManagerEntity lineManagerEntity)
        {
            _lineManagerDataAccess = new LineManagerDataAccess();
            if (_lineManagerDataAccess.Delete(lineManagerEntity))
            {
                return true;
            }
            ErrorMessage = _lineManagerDataAccess.ErrorMessage;
            return false;
        }
    }
}
